package controladores;



import modelo.datos.nivel_instruccion;
import modelo.hibernate.dao.DaoNivel_Instruccion;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Button;
import org.zkoss.zul.Intbox;
import org.zkoss.zul.ListModel;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Textbox;

public class controladorRegistrarNivel extends SelectorComposer<Component>{
	
private static final long serialVersionUID = 1L;
	
	private DaoNivel_Instruccion dao = new DaoNivel_Instruccion();
	private nivel_instruccion nivel = new nivel_instruccion();
	
	@Wire
	private Textbox codigo;
	@Wire
	private Textbox nombre;
	@Wire
	private Button btnRegistrar;
	@Wire
	private Button btnCancelar;
	
    @Listen("onClick=#btnRegistrar")
	public void onClick$btnRegistrar(MouseEvent event){

    	
    					nivel.setCodnivelinst(codigo.getValue());					
						nivel.setNomnivelinst(nombre.getValue());
		
					try {	
							dao.agregarNivel_Instruccion(nivel);
							
						
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();	
					}
					LimpiarCampos();
		}
	
    //}
    
    public void LimpiarCampos()
    {
    	codigo.setText("");
    	nombre.setText("");
    
    }
    
    @Listen("onClick=#btnCancelar")
   	public void onClick$btnCancelar(MouseEvent event){
    	Executions.sendRedirect("principal.zul");
    }
}
